package cn.gov.ssxmzj.controller;

import cn.gov.ssxmzj.entry.Result;
import cn.gov.ssxmzj.service.NewsService;
import cn.gov.ssxmzj.utils.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@Controller
@RequestMapping("/news")
@EnableAutoConfiguration
public class NewsController {

    @Autowired
    private NewsService service;

    @ResponseBody
    @RequestMapping("/getNews")
    public Result getNews(){
        return service.getNews();
    }

    @ResponseBody
    @RequestMapping("/getNewById")
    public Result getNewById(String newsId,boolean isManager){
        return service.getNewById(newsId,isManager);
    }

    @ResponseBody
    @RequestMapping("/getAllNewByType")
    public Result getAllNewByType(String newsType,int offset,int rows){
        return service.getAllNewByType(newsType,offset,rows);
    }

    @ResponseBody
    @RequestMapping("/getDownloadFileList")
    public Result getDownloadFileList(){
        return service.getDownloadFileList();
    }

    @ResponseBody
    @RequestMapping("/uploadNewsPic")
    public Map uploadNewsPic(MultipartFile file){
        return service.uploadNewsPic(file);
    }

    @ResponseBody
    @RequestMapping("/uploadServicePic")
    public Map uploadServicePic(MultipartFile file){
        return Utils.asMap("code","1","msg","暂不支持添加图片");
    }

}
